package com.zy.web.core.config;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.zy.business.domain.TbPunchCard;
import com.zy.business.service.PunchCardService;
import com.zy.quartz.config.RabbitConfig;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;


@Component
public class MailConsumer {

    @Autowired
    private PunchCardService punchCardService;

//    @RabbitListener(queues = RabbitConfig.MAIL_QUEUE_NAME)
//    public void consume(Message message, Channel channel) throws IOException {
//        String dataStr = new String(message.getBody());
//        System.out.println(dataStr);
//        int i = dataStr.indexOf("{");
//        dataStr = dataStr.substring(i);
//        int p = dataStr.lastIndexOf("}");
//        dataStr = dataStr.substring(i-1,p+1);
//        dataStr = dataStr.replaceAll("\\\\","");
//        JSONObject jsonObject = new JSONObject(dataStr);
//        TbPunchCard punchCard = JSONUtil.toBean(jsonObject, TbPunchCard.class);
//        punchCardService.sendSuccessMessage(punchCard);
//        channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
//    }

}
